package com.sy.simpleegg.platform.ychsdk.api

import com.sy.simpleegg.platform.ychsdk.bean.YchBuyPackageResp
import com.sy.simpleegg.platform.ychsdk.bean.pay.CardInfoBean
import com.sy.simpleegg.platform.ychsdk.bean.pay.ChannelGoodsInfoData
import com.sy.simpleegg.platform.ychsdk.bean.pay.ChannelWaitOffData
import com.sy.simpleegg.platform.ychsdk.bean.pay.GetOperationQrCodeData
import com.sy.simpleegg.platform.ychsdk.bean.pay.MemberTakeCoinResult
import com.sy.simpleegg.platform.ychsdk.bean.pay.PayResult
import com.sy.simpleegg.platform.ychsdk.bean.pay.QueryGroupStateData
import com.ych.ytdevicesdk.api.BaseResult
import io.reactivex.Observable
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST
import retrofit2.http.QueryMap


interface IPayApi {
    /**
     * 查询下单支付结果
     *
     * @param token token
     * @param map   订单信息
     * @return 支付结果
     */
    @GET("/yunyouminipos/api/v1/CoinExchange/BuyResult")
    fun queryBuyResult(
        @Header("Authorization") token: String?,
        @QueryMap map: Map<String?, @JvmSuppressWildcards Any?>?,
    ): Observable<BaseResult<PayResult?>?>?

    /**
     * 创建订单
     *
     * @param token token
     * @param map   订单信息
     * @return 订单号 支付二维码
     */
    @POST("/yunyouminipos/api/v1/CoinExchange/BuyPackage")
    fun createOrder(
        @Header("Authorization") token: String?,
        @Body map: Map<String?, @JvmSuppressWildcards Any?>?,
    ): Observable<BaseResult<YchBuyPackageResp?>?>?

    /**
     * 会员取币
     *
     * @param token token
     * @param map   TransID 需要唯一，LeaguerID 会员ID ，Amount 提币数量
     * @return
     */
    @POST("/yunyouminipos/api/v1/CoinExchange/ExtractCoin")
    fun memberTakeCoin(
        @Header("Authorization") token: String?,
        @Body map: Map<String?, Any?>?,
    ): Observable<BaseResult<MemberTakeCoinResult?>?>?

    /**
     * 提交出币结果
     *
     * @param token token
     * @param map   Count 实出币数， Expected 应出币数，Status 机台状态 ， Balance 机台余币 ， OrderID 订单ID
     * @return
     */
    @POST("/yunyouminipos/api/v1/CoinExchange/OutCoinRes")
    fun pullOutCoinResult(
        @Header("Authorization") token: String?,
        @Body map: Map<String?, @JvmSuppressWildcards Any?>?,
    ): Observable<BaseResult<Any?>?>?

    /**
     * 退单（敏感操作会直接退掉订单，用于取消反扫支付但未出币情况）
     *
     * @param token token
     * @param map   Result 错误码 0 成功 其他失败，Message 错误描述 ， OrderID 订单ID
     * @return
     */
    @POST("/yunyouminipos/api/v1/CoinExchange/ReturnPay")
    fun returnPay(
        @Header("Authorization") token: String?,
        @Body map: Map<String?, Any?>?,
    ): Observable<BaseResult<Any?>?>?

    /**
     * 上报非MQ提币的指令执行解结果
     *
     * @param token token
     * @param map   Result 错误码 0 成功 其他失败，Message 错误描述 ， OrderID 订单ID
     * @return
     */
    @POST("/yunyouminipos/api/v1/CoinExchange/SetStartResult")
    fun pullStartResult(
        @Header("Authorization") token: String?,
        @Body map: Map<String?, @JvmSuppressWildcards Any?>?,
    ): Observable<BaseResult<Any?>?>?

    /**
     * 提交现金出币结果
     *
     * @param token token
     * @param map   Count 实出币数， Expected 应出币数，Status 机台状态 ， Balance 机台余币 ， OrderID 订单ID
     * @return
     */
    @POST("/Hardware/api/v1.0/Pay/CashOrder")
    fun pullCashCoinResult(
        @Header("Authorization") token: String?,
        @Body map: Map<String?, @JvmSuppressWildcards Any?>?,
    ): Observable<BaseResult<Any?>?>?

    /**
     * 渠道取币
     *
     * @param token token
     * @param map   Code 团购码 String，Amount 核销数量 int ，Channel EnumChannelType [com.ych.cloudCoinDevice.config.Constants.EnumChannelType]
     * @return
     */
    @POST("/yunyouminipos/api/v1/CoinExchange/WriteOff")
    fun writeOffChannelGoodsToCoin(
        @Header("Authorization") token: String?,
        @Body map: Map<String?, @JvmSuppressWildcards Any?>?,
    ): Observable<BaseResult<ChannelWaitOffData?>?>?

    /**
     * 渠道取币
     *
     * @param token token
     * @param map   Code 团购码 String，DevNum 设备nem String ，Channel EnumChannelType [com.ych.cloudCoinDevice.config.Constants.EnumChannelType]
     * @return
     */
    //    @POST("/yunyouminipos/api/v1/CoinExchange/GroupQueryInfo")
    @POST("/yunyouminipos/api/v1/KoubeiWriteOff/QueryInfo")
    fun groupQueryInfo(
        @Header("Authorization") token: String?,
        @Body map: Map<String?, Any?>?,
    ): Observable<BaseResult<ChannelGoodsInfoData?>?>?

    /**
     * 查询团购码扫码状态
     *
     * @param token token
     * @param map   TransID
     * @return
     */
    @POST("/yunyouminipos/api/v1/CoinExchange/QeuryGroupState")
    fun queryGroupState(
        @Header("Authorization") token: String?,
        @Body map: Map<String?, Any?>?,
    ): Observable<BaseResult<QueryGroupStateData?>?>?

    /**
     * 获取操作二维码
     * @param token token
     * @param map   Code 团购码 String，DevNum 设备nem String ，Channel EnumChannelType [com.ych.cloudCoinDevice.config.Constants.EnumChannelType]
     * @return
     */
    @POST("/yunyouminipos/api/v1/CoinExchange/GetOperationQRCode")
    fun getOperationQRCode(
        @Header("Authorization") token: String?,
        @Body map: Map<String?, Any?>?,
    ): Observable<BaseResult<GetOperationQrCodeData?>?>?

    /**
     * 取消订单
     *
     * @param token token
     * @param map   TransID  需要唯一，
     * @return
     */
    @GET("/yunyouminipos/api/v1/CoinExchange/CancelPay")
    fun cancelOrder(
        @Header("Authorization") token: String?,
        @QueryMap map: Map<String?, Any?>?,
    ): Observable<BaseResult<Any?>?>?

    /**
     * 取消订单
     *
     * @param token token
     * @param map   TransID  需要唯一，
     * @return
     */
    @GET("/yunyouminipos/api/v1/Leaguer/CardLeaguerInfo")
    fun cardLeagueInfo(
        @Header("Authorization") token: String?,
        @QueryMap map: Map<String?, Any?>?,
    ): Observable<BaseResult<CardInfoBean?>?>?
}